1. /* siosiand.cpp by K.Tsuru */
  2. // function ID = 408 DRADIX, BRADIX
  3. /*******************************************
  4. SInteger class
  5. It provides the bit "and" oparattion m & n.
  6. ********************************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. SInteger operator&(const SInteger& m, const SInteger& n){
  11. if( m.Sign(408) == 0) return m; // return 0.0;
  12. if( n.Sign(408) == 0) return n;
  13. const fType* mv;
  14. const fType* nv;
  15. uint t, h;
  16. mv = m.ReadFigures();
  17. nv = n.ReadFigures();
  18. h = max(m.Head(), n.Head()); // aHead --> Head() since ver 2.191
  19. t = min(m.Tail(), n.Tail());
  20. SInteger result;
  21. if( h < t ) {
  22. result.SetZero(); return result; // ver.2.17
  23. }
  24. result.valloc(h + 1u, -1);
  25. result.figure.clear(0, t);
  26. result.figure.clear(h + 1u);
  27. fType* rv = result.figure.Elements();
  28. for(register uint i = t; i <= h; i++){
  29. rv[i] = mv[i] & nv[i];
  30. }
  31. while( !rv[t] && t <= h ) t++;
  32. if( h < t ) { // Here rv[h] = 0 and t = h + 1 i.e. result = 0.
  33. result.SetZero(); return result; // ver.2.17
  34. }
  35. // Below result != 0.
  36. result.aTail = t;
  37. while( !rv[h] && h > t ) h--;
  38. result.aHead = h;
  39. result.SetSign(1);
  40. // It reduces the size if possible.
  41. if( 2u * (result.aHead + 1) <= result.figure.size() ) result.DoCutDown();
  42. return result;
  43. }

siosiand.cpp : last modifiled at 2017/03/13 14:32:00(1,301 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).